/*Prepared Using STATA 19 MP: September 19, 2025*/
cap cd "C:\Users\ejm5\Dropbox\Vietnam Election project\2021_Election\Replication"
use "9_election_working.dta", clear
set scheme plottig

*******************************************************************************************************
/*Table 1: Descriptive Statistics of Outcome Variables for Control Group*/
/*log using "Tables\Table2_Descriptives.smcl", replace*/
estpost summarize Vote no_names no_positions Q11_7  vote_directly vote_proxy VNALegitimacy_all VNAConfidence_all   if treatment_group==0 & Vote<=1 
esttab using "Tables\Table1", cells("count mean sd min max") replace
/*log close*/
*******************************************************************************************************
******************************************************************************************************************
/*Table 2: OLS Hypothesis 1: Mobilization Efforts Did Not Have Significant Effect on Voting Behavior*/

reg Vote T1 T2 T3, cluster(votingdivision2)
outreg2 using "Tables\Table2", bdec(3) tdec(3) e(rmse N_clust) ctitle("Vote") label addtext("Block FE", No, "Major FE", No, "City FE", No, "Questionnaire_order", No) stats(coef pval) noaster drop(Vote)  replace
areg Vote T1 T2 T3 major1 major2 HCMC Questionnaire_order, cluster(votingdivision2) absorb(strata) 
outreg2 using "Tables\Table2", bdec(3) tdec(3) e(rmse N_clust) ctitle("Vote") label addtext("Block FE", Yes, "Major FE", Yes, "City FE", Yes, "Questionnaire_order", No) keep(T1 T2 T3) stats(coef pval) noaster

reg  no_names T1 T2 T3, cluster(votingdivision2)
outreg2 using "Tables\Table2", bdec(3) tdec(3) e(rmse N_clust) ctitle("Name Candidates (#)") label addtext("Block FE", No, "Major FE", No, "City FE", No, "Questionnaire_order", No) stats(coef pval) drop(no_names) noaster
areg no_names T1 T2 T3 major1 major2 HCMC Questionnaire_order, cluster(votingdivision2) absorb(strata) 
outreg2 using "Tables\Table2", bdec(3) tdec(3) e(rmse N_clust) ctitle("Name Candidates (#)") label addtext("Block FE", Yes, "Major FE", Yes, "City FE", Yes, "Questionnaire_order", Yes) keep(T1 T2 T3) stats(coef pval) noaster
 
reg no_positions T1 T2 T3, cluster(votingdivision2)
outreg2 using "Tables\Table2", bdec(3) tdec(3) e(rmse N_clust) ctitle("Name Positions (#)") label addtext("Block FE", No, "Major FE", No, "City FE", No, "Questionnaire_order", No) stats(coef pval) drop(no_positions) noaster
areg no_positions T1 T2 T3 major1 major2 HCMC Questionnaire_order, cluster(votingdivision2) absorb(strata)
outreg2 using "Tables\Table2", bdec(3) tdec(3) e(rmse N_clust) ctitle("Name Positions (#)") label addtext("Block FE", Yes, "Major FE", Yes, "City FE", Yes, "Questionnaire_order", Yes) keep(T1 T2 T3) stats(coef pval) noaster

reg Q11_7 T1 T2 T3, cluster(votingdivision2)
outreg2 using "Tables\Table2", bdec(3) tdec(3) e(rmse N_clust) ctitle("Vote for Positive Change") label addtext("Block FE", No, "Major FE", No, "City FE", No, "Questionnaire_order", No) keep(T1 T2 T3) stats(coef pval) noaster
areg Q11_7 T1 T2 T3 major1 major2 HCMC Questionnaire_order, cluster(votingdivision2) absorb(strata)
outreg2 using "Tables\Table2", bdec(3) tdec(3) e(rmse N_clust) ctitle("Vote for Positive Change") label addtext("Block FE", Yes, "Major FE", Yes, "City FE", Yes, "Questionnaire_order", Yes) keep(T1 T2 T3) stats(coef pval) noaster excel

/********Multiple Comparisons*****************************/
/*log using "Tables\Table2_wyoung_p.smcl", replace*/
/*Model without Control Variables 1, 3, 5, 7*/
wyoung Vote no_names no_positions Q11_7, cmd(reg OUTCOMEVAR T1 T2 T3, cluster(votingdivision2))  familyp(T1 T2 T3) bootstraps(1000) seed(20241016) cluster(votingdivision2)
/*Model without Control Variables 2, 4, 6, 8*/
wyoung Vote no_names no_positions Q11_7, cmd(reg OUTCOMEVAR T1 T2 T3 CONTROLVARS, cluster(votingdivision2)) controls("major1 major2 HCMC Questionnaire_order strata2 strata3 strata4 strata5 strata6" "major1 major2 HCMC Questionnaire_order strata2 strata3 strata4 strata5 strata6" "major1 major2 HCMC Questionnaire_order strata2 strata3 strata4 strata5 strata6" "major1 major2 HCMC Questionnaire_order strata2 strata3 strata4 strata5 strata6")  familyp(T1 T2 T3) bootstraps(1000) seed(20241016) cluster(votingdivision2)
/*log close*/
 
***********************************************************************************************************************************************************************************************************************************
/*Figure 2 "Civic Educations Reduces Proxy Voting, Candidate Information Reduces Direct Voting"*/
preserve
replace vote_directly=vote_directly*100
replace vote_proxy=vote_proxy*100

graph bar (mean) vote_directly (mean) vote_proxy, over(treatment_group) stack blabel(bar, size(small) color(black) position(inside) format(%9.2f)) legend(rows(2) ring(0) size(small) position(11) label(1 "Vote Directly") label(2 "Vote by Proxy")) ylab(0(10)100, labsize(small)) ytitle("Share of Respondents (%)", size(medium)) bar(1, fcolor(pink) lcolor(pink))
graph save "Figures\Figure2.gph", replace
graph export "Figures\Figure2.pdf", as(pdf) replace
restore

***********************************************************************************************************************************************************************************************************************************
/*Table 3: Hypothesis 2: Civic Education Increases Interest in VNA*/ 

reg  VNALegitimacy_all T1 T2 T3, robust
outreg2 using "Tables\Table3", bdec(3) tdec(3) e(rmse N_clust) ctitle("Will Watch VNA=1") label addtext("Block FE", No, "Major FE", No, "City FE", No, "Questionnaire_order", No) keep(T1 T2 T3) stats(coef pval) noaster replace
areg VNALegitimacy_all T1 T2 T3 major1 major2 HCMC Questionnaire_order, robust absorb(strata)
outreg2 using "Tables\Table3", bdec(3) tdec(3) e(rmse N_clust) ctitle("Will Watch VNA=1") label addtext("Block FE", Yes, "Major FE", Yes, "City FE", Yes, "Questionnaire_order", Yes) keep(T1 T2 T3) stats(coef pval) noaster 
 
reg VNAConfidence_all T1 T2 T3, robust
outreg2 using "Tables\Table3", bdec(3) tdec(3) e(rmse N_clust) ctitle("Confidence in VNA (1-10)") label addtext("Block FE", No, "Major FE", No, "City FE", No, "Questionnaire_order", No) keep(T1 T2 T3) stats(coef pval) noaster
areg VNAConfidence_all T1 T2 T3 major1 major2 HCMC Questionnaire_order, robust absorb(strata)
outreg2 using "Tables\Table3", bdec(3) tdec(3) e(rmse N_clust) ctitle("Confidence in VNA (1-10)") label addtext("Block FE", Yes, "Major FE", Yes, "City FE", Yes, "Questionnaire_order", Yes) keep(T1 T2 T3) stats(coef pval) noaster   excel

/********Multiple Comparisons*****************************/
/*log using "Tables\Table3_wyoung_p.smcl", replace*/
wyoung VNALegitimacy_all VNAConfidence_all, cmd(reg OUTCOMEVAR T1 T2 T3, cluster(votingdivision2))  familyp(T1 T2 T3) bootstraps(1000) seed(20241016) cluster(votingdivision2)

wyoung VNALegitimacy_all VNAConfidence_all, cmd(reg OUTCOMEVAR T1 T2 T3 CONTROLVARS, cluster(votingdivision2)) controls("major1 major2 HCMC Questionnaire_order" "major1 major2 HCMC Questionnaire_order")  familyp(T1 T2 T3) bootstraps(1000) seed(20241016) cluster(votingdivision2)
/*log close*/

*******************************************************************************************************************************************************************************************************************************
/*Figure 3: Regime Outsiders Disincentivized to Vote*/
wildbootstrap reg Vote i.T1##i.polibg  i.T2##i.polibg  i.T3##i.polibg   major1 major2 HCMC Question , cluster(votingdivision2)  rseed(11062024)
margins, dydx(T1) by(polibg ) level(95)
marginsplot, recast(scatter) xtitle("", size(medium)) ytitle("", size(medium)) title("T1: Civic Education", position(12) span) yline(0, lcolor(red) lpattern(dash) lwidth(thin))  ciopts(lcolor(navy) lwidth(medthick))
graph save "Figures\margins_T1.gph", replace

wildbootstrap reg Vote i.T1##i.polibg  i.T2##i.polibg  i.T3##i.polibg   major1 major2 HCMC Question , cluster(votingdivision2)  rseed(11062024)
margins, dydx(T2) by(polibg ) level(95)
marginsplot, recast(scatter) xtitle("", size(medium)) ytitle("", size(medium)) title("T2: Candidate Biography", position(12) span) yline(0, lcolor(red) lpattern(dash) lwidth(thin))  ciopts(lcolor(navy) lwidth(medthick))
graph save "Figures\margins_T2.gph", replace

wildbootstrap reg Vote i.T1##i.polibg  i.T2##i.polibg  i.T3##i.polibg   major1 major2 HCMC Question , cluster(votingdivision2)  rseed(11062024)
margins, dydx(T3) by(polibg ) level(95)
marginsplot, recast(scatter) xtitle("", size(medium)) ytitle("", size(medium)) title("T3: Legislative Docket", position(12) span) yline(0, lcolor(red) lpattern(dash) lwidth(thin))  ciopts(lcolor(navy) lwidth(medthick))
graph save "Figures\margins_T3.gph", replace

/*Figure 3: Marginal Effects Plot*/
graph combine "Figures\margins_T1.gph" "Figures\margins_T2.gph" "Figures\margins_T3.gph",xcommon imargin(tiny) title("Regime Insider?", size(medium) position(6)) subtitle("Conditional Average Treatment Effects", position(9) orientation(vertical) size(medium)) rows(1)  
graph save "Figures\Figure3.gph", replace
graph export "Figures\Figure3.pdf", as(pdf) replace
*******************************************************************************************************************************************************************************************************************************
/*Figure 4: No Difference between Outsiders and Insiders Regarding Interest in the VNA*/
wildbootstrap reg VNALegitimacy_all i.T1##i.polibg  i.T2##i.polibg  i.T3##i.polibg   major1 major2 HCMC Question , cluster(votingdivision2) rseed(11062024)
margins, dydx(T1) by(polibg ) level(95)
marginsplot, recast(scatter) xtitle("", size(medium)) ytitle("", size(medium)) title("T1: Civic Education", position(12) span) yline(0, lcolor(red) lpattern(dash) lwidth(thin))  ciopts(lcolor(navy) lwidth(medthick))
graph save "Figures\margins_T1.gph", replace

wildbootstrap reg VNALegitimacy_all i.T1##i.polibg  i.T2##i.polibg  i.T3##i.polibg   major1 major2 HCMC Question , cluster(votingdivision2) rseed(11062024)
margins, dydx(T2) by(polibg ) level(95)
marginsplot, recast(scatter) xtitle("", size(medium)) ytitle("", size(medium)) title("T2: Candidate Biography", position(12) span) yline(0, lcolor(red) lpattern(dash) lwidth(thin))  ciopts(lcolor(navy) lwidth(medthick))
graph save "Figures\margins_T2.gph", replace

wildbootstrap reg VNALegitimacy_all i.T1##i.polibg  i.T2##i.polibg  i.T3##i.polibg   major1 major2 HCMC Question , cluster(votingdivision2) rseed(11062024)
margins, dydx(T3) by(polibg ) level(95)
marginsplot, recast(scatter) xtitle("", size(medium)) ytitle("", size(medium)) title("T3: Legislative Docket", position(12) span) yline(0, lcolor(red) lpattern(dash) lwidth(thin))  ciopts(lcolor(navy) lwidth(medthick))
graph save "Figures\margins_T3.gph", replace

/*Figure 4**/
graph combine "Figures\margins_T1.gph" "Figures\margins_T2.gph" "Figures\margins_T3.gph",xcommon imargin(tiny) title("Regime Insider?", size(medium) position(6)) subtitle("Subgroup Effects of Treatments", position(9) orientation(vertical) size(medium)) rows(1)  
graph save "Figures\Figure4.gph", replace
graph export "Figures\Figure4.pdf", as(pdf) replace
*******************************************************************************************************************************************************************************************************************************









